package com.java.concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * D
 *
 * @author wwm
 * @create 2017-04-19 18:19
 **/
public class TestPro  implements Callable<Integer>  {
    AtomicInteger atomicInteger = null;

    public  TestPro(AtomicInteger atomicInteger1){
        this.atomicInteger=atomicInteger1;
    }

    public   Integer call() throws Exception {

            System.out.println("pro:" + atomicInteger.get());
            System.out.println("pro-threadname:"+Thread.currentThread().getName());
            System.out.println("pro-threadid:"+Thread.currentThread().getId());

//        Lock lock = new ReentrantLock();
//        lock.lock();
//        try {
            atomicInteger.addAndGet(1);
//        }finally {
//            lock.unlock();
//        }

        return atomicInteger.get() ;
    }
}
